/**
 * problem_002.c
 * Copyright (C) 2011-03-17 - xrose
 * By considering the terms in the Fibonacci sequence whose values do not exceed
 * four million, find the sum of the even-valued terms.
 * result: 4613732
 */
#include <stdio.h>
#define MAXF 4000000
int main (int argc, char *argv[])
{
    int fi, fo, fn, sum;
    printf("%d\n", sizeof(int));

    fi = 1;
    fo = 1;
    sum = 0;
    do
    {
        fn =fo + fi;
        if(fn%2 == 0)
        {
            sum += fn;
        }
        fo = fi;
        fi = fn;
    } while (fi+fo<=MAXF);
    printf("sum of the fibonaci sequence even-valued: %ld\n", sum);
    return 0;
}
